package com.music.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;

import com.music.R;

/**
 * 闪屏页面，即 启动页面
 * 在此页面启动音乐播放服务，即PlayService。
 * 此页面的handler是匿名内部类可能会造成内存泄漏。
 */
public class SplashActivity extends Activity {
	private static final int START_ACTIVITY = 0x1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

		startService(new Intent(this, PlayService.class));//开启服务

		setContentView(R.layout.activity_start);

		handler.sendEmptyMessageDelayed(START_ACTIVITY, 3000);
	}

	Handler handler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			super.handleMessage(msg);
			switch (msg.what) {
				case START_ACTIVITY:
					startActivity(new Intent(SplashActivity.this, LocalMusicActivity.class));
					finish();
					break;

			}

		}

		;
	};

}
